public class scrPanal extends javax.swing.JDesktopPane implements Runnable{
	private java.net.Socket socket=null;
	private java.awt.Dimension dimension=null;
	public scrPanal(java.net.Socket s,java.awt.Dimension d){
		this.socket = s;
		this.dimension = d;
		try{
			java.io.OutputStream out = socket.getOutputStream();
			String data="screen\r\n";
			out.write(data.getBytes());
			out.flush();
			new Thread(this).start();
		}catch(Exception e){
			e.printStackTrace();
		}
	} 
	public void run(){
		try{
			do{
				repaint();
				Thread.sleep(30);
			}while(true);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public void paintComponent(java.awt.Graphics g){
		super.paintComponent(g);
	    java.awt.Graphics2D g2 = (java.awt.Graphics2D)g;
	    try{

	    	com.sun.image.codec.jpeg.JPEGImageDecoder decoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGDecoder(socket.getInputStream());
	    	java.awt.image.BufferedImage bufferedImage = decoder.decodeAsBufferedImage();
	    	if(bufferedImage!=null){
	    		g2.drawImage(bufferedImage , 0, 0, (int)dimension.width, (int)dimension.height,  null);
	    	}

	    }catch(Exception e){
	    	e.printStackTrace();
	    }
	}
}
